home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Sound / delfinampeg / src / PCM.a56 < prev    next >
Text File  |  2001-06-14  |  4KB  |  195 lines

  1. ;*****************************************************************************
  2. ;
  3. ;    delfinampeg.device - mpeg.device for Delfina DSP
  4. ;    Copyright (C) 2000, 2001  Michael Henke
  5. ;
  6. ;    This program is free software; you can redistribute it and/or modify
  7. ;    it under the terms of the GNU General Public License as published by
  8. ;    the Free Software Foundation; either version 2 of the License, or
  9. ;    (at your option) any later version.
  10. ;
  11. ;    This program is distributed in the hope that it will be useful,
  12. ;    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;    GNU General Public License for more details.
  15. ;
  16. ;    You should have received a copy of the GNU General Public License
  17. ;    along with this program; if not, write to the Free Software
  18. ;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. ;
  20. ;*****************************************************************************
  21.  
  22.  
  23.  
  24. ;(Mon 30-Oct-2000) - added separate left/right volume (balance)
  25.  
  26.  
  27.  
  28. ;Delfina object DSP56K_PCM
  29. ;memory map (for Amiga access)
  30. ;
  31. ; prog
  32. ;   0 .. init (x1=mono, x0=volume_left, y1=freq, y0=volume_right)
  33. ;  +2 .. mute (x1=/, x0=/, y1=/, y0=/)
  34. ;  +4 .. DelfModule
  35. ;
  36. ; xdata
  37. ;   /
  38. ;
  39. ; ydata
  40. ;   0 .. amybuf (Amiga read)
  41.  
  42.  
  43.  
  44.  
  45. DELFINA_SAMPLES    equ    1152
  46.  
  47.  
  48.     include 'delfequ.inc'
  49.  
  50.     org    p:
  51.  
  52. int_key
  53.  
  54. ;->prog
  55.     jmp    init
  56.  
  57. ;->prog+2
  58.     jmp    mute
  59.  
  60.  
  61. ;->prog+4
  62.  
  63. ;***********************************
  64. ;* play routine
  65. ;*
  66. ;* r1=list of play buffers
  67.  
  68. ;****    sampling rate conversion
  69.     move    y:(r1),r4        ;r4=output buf
  70.     move    r4,r7            ;r7=copy of r4
  71.     move    #rateconv,r3        ;r3=rateconv structure
  72.     move    x:bufptr,r6        ;r6=old bufptr
  73.  
  74.     movec    #DELFINA_SAMPLES*2-1,m2 ;m2=input buffer mask
  75.     jsr    <delf_playrate        ;rate conversion
  76.  
  77.  
  78. ;****    duplicate left channel for mono output
  79.     movec    m0,m7            ;#$ffff
  80.     move    y:mono,b
  81.     tst    b    r7,r0
  82.     jeq    not_mono
  83.     move    r7,n7
  84.     move    x:(r0)+,a
  85.     rep    #127
  86.     move    x:(r0)+,a    a,y:(r7)+
  87.     move    a,y:(r7)
  88.     move    n7,r7
  89. not_mono
  90.  
  91.  
  92. ;****    volume adjustment
  93.     move    y:volume_left,x1
  94.     move    y:volume_right,y1
  95.     move    #<$40,a            ;0.5 = 100%
  96.     cmp    x1,a    r7,r0
  97.     jne    volume
  98.     cmp    y1,a
  99.     jeq    no_volume
  100. volume
  101.     ori    #$08,mr                    ;SCALE UP mode
  102.     movec    m0,m5            ;#$ffff
  103.     move    r7,r5
  104.     move    r7,r1
  105.  
  106.     move            x:(r0)+,x0    y:(r5)+,y0
  107.     mpyr    x0,x1,a        x:(r0)+,x0
  108.     mpyr    y0,y1,b        a,x:(r1)+    y:(r5)+,y0
  109.     do    #127,volume_loop
  110.     mpyr    x0,x1,a        x:(r0)+,x0    b,y:(r7)+
  111.     mpyr    y0,y1,b        a,x:(r1)+    y:(r5)+,y0
  112. volume_loop
  113.     move                    b,y:(r7)+
  114.  
  115.     andi    #$f3,mr                    ;NO SCALING mode
  116. no_volume
  117.     
  118.  
  119. ;****    double buffering
  120.     move    r6,y1            ;y1=old pointer
  121.     move    y:buf2,b        ;b= start of buf2
  122.     cmp    y1,b    r2,y0        ;y0=new pointer
  123.     jle    dbuf_buf2
  124.     cmp    y0,b    y:buf1,x0
  125.     jgt    dbuf_skip
  126. dbuf_int
  127.     move    x0,y:amybuf        ;tell amiga the new buffer
  128.     move    #int_key,a0
  129.     move    #causeqw,r0
  130.     jmp    <delf_causeq        ;interrupt and exit
  131. dbuf_buf2
  132.     cmp    y0,b    b,x0
  133.     jgt    dbuf_int
  134. dbuf_skip
  135.     rts
  136.  
  137.  
  138.  
  139. ;***********************************
  140. ;* init stuff
  141. ;*
  142. ;* x1=mono
  143. ;* x0=volume_left
  144. ;* y1=freq
  145. ;* y0=volume_right
  146. init
  147.     move    x1,y:mono
  148.     move    x0,y:volume_left
  149.     move    y1,x:freq
  150.     move    y0,y:volume_right
  151.     rts
  152.  
  153.  
  154. ;***********************************
  155. ;* clear current buffer (pause mode)
  156. ;*
  157. ;* x1=/
  158. ;* x0=/
  159. ;* y1=/
  160. ;* y0=/
  161. mute
  162.     clr    a    y:amybuf,r0
  163.     do    #DELFINA_SAMPLES,mute_loop    ;slower than 'rep'...
  164.     move    a,l:(r0)+            ;...but it's interruptable
  165. mute_loop
  166.     move    a,x0
  167.     rts
  168.  
  169.  
  170.  
  171.  
  172.     org    l:
  173.     align    4096        ;must be >= DELFINA_SAMPLES*2
  174. buf    ds    DELFINA_SAMPLES*2
  175.  
  176.  
  177.     org    x:
  178. causeqw    dc    0,0
  179. rateconv
  180. freq    dc    0
  181. bufptr    dc    buf
  182.     ds    4
  183.     
  184.     org    y:
  185. ;->ydata
  186. amybuf    dc    buf
  187.  
  188. mono    dc    0
  189. volume_left    dc    0.5
  190. volume_right    dc    0.5
  191.  
  192. buf1    dc    buf
  193. buf2    dc    buf+DELFINA_SAMPLES
  194.  
  195.